<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="bp" value="${pageContext.request.contextPath}"></c:set>
<html>
<head>
    <meta charset="utf-8">
    <title>登录</title>
    <!-- metatags-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
    function hideURLbar(){ window.scrollTo(0,1); } </script>
    <!-- Meta tag Keywords -->
    <!-- Custom-Style-Sheet -->
    <link href="${bp}/static/css/popuo-box.css" rel="stylesheet" type="text/css" media="all" />
    <link href="${bp}/static/css/style1.css" rel="stylesheet" type="text/css" media="all"/><!--style_sheet-->
    <link rel="stylesheet" href="${bp}/static/css/flexslider.css" type="text/css" media="screen" property="" />
    <link rel="stylesheet" href="${bp}/static/css/font-awesome.css"> <!-- Font-Awesome_Icons-CSS -->
    <!--//Custom-Style-Sheet -->
    <!--online_fonts-->
    <link href="http://maxcdn.bootstrapcdn.com/css?family=Audiowide" rel="stylesheet">
    <link href="http://maxcdn.bootstrapcdn.com/css?family=Montserrat+Alternates" rel="stylesheet">
    <!--//online_fonts-->
</head>
<body>
<div class="w3l-head">
    <h1>蛋糕之家</h1>
</div>
<div class="w3l-main">
    <div class="w3l-left-side">

        <div class="flexslider">
            <ul class="slides">
                <li>
                    <img width="600px" height="650px" src="${bp}/static/images/a1.jpg" alt="image"/>
                </li>
                <li>
                    <img width="600px" height="650px" src="${bp}/static/images/a2.jpg" alt="image"/>
                </li>
                <li>
                    <img width="600px" height="650px" src="${bp}/static/images/a3.jpg" alt="image"/>
                </li>
                <li>
                    <img width="600px" height="650px" src="${bp}/static/images/a4.jpg" alt="image"/>
                </li>
                <li>
                    <img width="600px" height="650px" src="${bp}/static/images/a5.jpg" alt="image"/>
                </li>
            </ul>
        </div>
    </div>

    <div class="w3l-rigt-side">
        <div class="w3l-signin">
            <a class="w3_play_icon1" href="#small-dialog1"> 登录</a>
        </div>
        <div class="w3l-signup">
            <a class="w3_play_icon1" href="#small-dialog2"> 报名</a>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>

<!--sign in form -->
<div id="small-dialog1" class="mfp-hide">
    <div class="wthree-container">
        <div class="wthree-form">
            <div class="agileits-2">
                <h2>登录</h2>
            </div>

            <div class="w3-user">
                <span><i class="fa fa-user-o" aria-hidden="true"></i></span>
                <input type="text" id="username" placeholder="username" required="">
            </div>
            <div class="clear"></div>
            <div class="w3-psw">
                <span><i class="fa fa-key" aria-hidden="true"></i></span>
                <input type="password" id="password" placeholder="password" required="">
            </div>
            <div class="clear"></div>
            <div class="w3l-check">
                <input type="checkbox" class="checkbox">
                <span><a href="#">forgot password ?</a></span>
            </div>
            <div class="clear"></div>
            <div class="signin">
                <button onclick="login()"  value="登录">登录</button>
                <button onclick="insert()" value="注册">注册</button>
            </div>
            <div class="clear"></div>

        </div>
    </div>
</div>
<!--sign in form -->
<!-- for register popup -->

<!--sign up form -->
<div id="small-dialog2" class="mfp-hide">
    <div class="wthree-container">
        <div class="wthree-form bg">
            <div class="agileits-2">
                <h2>报名</h2>
            </div>
            <div class="w3-user">
                <span><i class="fa fa-user-o" aria-hidden="true"></i></span>
                <input type="text" name="Username" placeholder="Username" required="">
            </div>
            <div class="clear"></div>
            <div class="w3-email">
                <span><i class="fa fa-envelope" aria-hidden="true"></i></span>
                <input type="email" name="email" placeholder="Example@mail" required=""/>
            </div>
            <div class="clear"></div>
            <div class="w3-psw">
                <span><i class="fa fa-key" aria-hidden="true"></i></span>
                <input type="password" name="password" placeholder="Password" required="">
            </div>
            <div class="w3-cpsw">
                <span><i class="fa fa-key" aria-hidden="true"></i></span>
                <input type="password" name="password" placeholder="confirm-Password" required="">
            </div>
            <div class="clear"></div>
            <div class="w3l-check">
                <input type="checkbox" class="checkbox">
                <span><a href="#">i agree terms and conditions</a></span>
            </div>
            <div class="clear"></div>
            <div class="signin">
                <input type="submit" value="报名">
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<!--sign in form -->
<!-- //for register popup -->
<footer>Copyright &copy; 2018.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/"></a></footer>


<script type="text/javascript" src="${bp}/static/js/jquery-2.1.4.min.js"></script>

<!-- pop-up-box-js-file -->
<script src="${bp}/static/js/jquery.magnific-popup.js" type="text/javascript"></script>
<!--//pop-up-box-js-file -->
<script>
    $(document).ready(function() {
        $('.w3_play_icon,.w3_play_icon1,.w3_play_icon2').magnificPopup({
            type: 'inline',
            fixedContentPos: false,
            fixedBgPos: true,
            overflowY: 'auto',
            closeBtnInside: true,
            preloader: false,
            midClick: true,
            removalDelay: 300,
            mainClass: 'my-mfp-zoom-in'
        });

    });
</script>
<!-- flexSlider -->
<script defer src="${bp}/static/js/jquery.flexslider.js"></script>
<script type="text/javascript">
    $(window).load(function(){
        $('.flexslider').flexslider({
            animation: "slide",
            start: function(slider){
                $('body').removeClass('loading');
            }
        });
    });
    function login() {
        var username = $("#username").val()
        var password = $("#password").val()
        if(username == "" || username.length == 0){
            alert("请输入用户名")
            return false
        }
        if(password == "" || password.length == 0){
            alert("请输入密码")
            return false
        }
        $.ajax({
            type:"get",
            url:"${bp}/user/findByName",
            data:{"username":username,"password":password},
            success : function (msg) {
                if(msg == 0){
                    alert("密码错误")
                }
                if(msg == 1){
                    alert("登录成功")
                    window.location.href ="${bp}/cake/index"
                }
                if(msg == 2){
                    alert("登录失败")

                }


            }
        })
    }
    function insert() {
        var username = $("#username").val()
        var password = $("#password").val()
        if(username == "" || username.length == 0){
            alert("请输入用户名")
            return false
        }
        if(password == "" || password.length == 0){
            alert("请输入密码")
            return false
        }
        $.ajax({
            type:"post",
            url:"${bp}/user/insert",
            data:{"username":username,"password":password},
            success : function (msg) {
                if(msg == 1){
                    alert("注册成功")
                }else{
                    alert("注册失败")
                }
            }
        })
    }
</script>
<!-- //flexSlider -->
</body>
</html>